package com.carhailing.client.controller;

import com.carhailing.client.service.ClientService;
import com.carhailing.common.domain.request.PageInfoVo;
import com.carhailing.common.domain.response.*;

import com.carhailing.common.result.PageResult;
import com.carhailing.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Client")
public class ClientController {
    @Autowired
    private ClientService clientService;

    /**
     * 用户发起订单
     * @return
     */
    @PostMapping("/InitiateOrder")
    public Result InitiateOrder(@RequestBody StartCarOrder startCarOrder){
        Result result=clientService.InitiateOrder(startCarOrder);
        return result;
    }

    /**
     * 司机接单
     * @return
     */
    @PostMapping("/DriverTakeOrder/{orderTradeId}")
    public Result DriverTakeOrder(@PathVariable Integer orderTradeId){
        Result result=clientService.DriverTakeOrder(orderTradeId);
        return result;
    }

    /**
     * 订单列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/OrderList")
    public Result<PageResult<CarOrder>> OrderList(@RequestBody PageInfoVo pageInfoVo){
        Result<PageResult<CarOrder>> list=clientService.OrderList(pageInfoVo);
        return list;
    }

    /**
     * 时间
     * @param depLongitude
     * @param depLatitude
     * @param destLongitude
     * @param destLatitude
     * @return
     */
    @PostMapping("/forecastPrice")
    public ResponseResult forecastPrice(@RequestParam String depLongitude, String depLatitude, String destLongitude, String destLatitude) {
        return clientService.forecastPrice(depLongitude,depLatitude,destLongitude,destLatitude);
    }

    /**
     * 预约单
     * @return
     */
    @PostMapping("/reservation")
    public Result reservation(@RequestBody BookingCarOrder BookingCarOrder){
        Result result=clientService.reservation(BookingCarOrder);
        return result;
    }


    /**
     * 接机单
     * @param receivePlaneOrderDto
     * @return
     */
    @PostMapping("/airportPickup")
    public Result airportPickup(@RequestBody ReceivePlaneOrderDto receivePlaneOrderDto){
        Result result=clientService.airportPickup(receivePlaneOrderDto);
        return result;
    }




}
